package com.tmt.asm.invoker;

import java.lang.reflect.Method;

import javassist.ClassPool;
import javassist.CtClass;
import javassist.NotFoundException;

public class JavassistInvoker {

	public JavassistInvoker(Class<?> serviceType, Object service) throws NotFoundException {
		ClassPool pool = ClassPool.getDefault();
		CtClass invokerCtClass = pool.makeClass("com.tmt.asm.invoker.gen." + serviceType.getSimpleName());
		invokerCtClass.setInterfaces(new CtClass[] { pool.getCtClass(serviceType.getName()) });

		Method[] methods = serviceType.getDeclaredMethods();
		for (Method method : methods) {
			StringBuilder methodBuilder = new StringBuilder();
			methodBuilder.append("public ");
			methodBuilder.append(method.getReturnType().getName());
			methodBuilder.append(" ").append(method.getName());
			
			//CtMethod method = CtNewMethod.make("public void code(){}", cc); 
		}
	}
}
